<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>echarts-一个容器多个表格的其他写法</title>
    <style>
      .charts {
        width: 800px;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <div class="charts"></div>
    <script src="./echarts.min.js"></script>
    <script>
      const myEcharts = echarts.init(document.querySelector(".charts"));
      const option = {
        xAxis:{
          type:'category' // 如果写了data，那么就不用type
        },
        yAxis:{},
        //  数据集 把数据都定义在这
        dataset: {
          // 二维数组
          source: [
            // [0,1,2,3,4]
            ["周一", 11, 22, "xxx", 111],
            ["周二", 21, 32, "yyy", 222],
            ["周三", 15, 18, "zzz", 333],
            ["周四", 13, 22],
            ["周五", 18, 23],
            ["周六", 26, 29],
            ["周日", 22, 19],
          ],
        },
        series: [
          {
            type: "bar",
            //  使用dataset中的数据
            // x是x轴
            // y是y轴
            encode: { x: 0, y: 1 },
          },
          {
            type: "line",
            encode: { x: 0, y: 2 },
          },
          {
            type: "pie",
            encode: { itemName: 3, value: 4 },
            radius: 30, // 半径
            center: [600, 50], // 圆心
          },
        ],
      };
      myEcharts.setOption(option);
    </script>
  </body>
</html>
